package com.ymatou.iapi.fundcommission.testcase;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.fundcommission.service.ChargeCommissionRateGetCall;
import com.ymatou.iapi.fundstrategy.parameter.FundStrategy;
import com.ymatou.iapi.fundstrategy.parameter.FundStrategyCreateBean;
import com.ymatou.iapi.fundstrategy.parameter.FundStrategyQueryBean;
import com.ymatou.iapi.fundstrategy.parameter.YmtFundDimensiongetDimensionid;
import com.ymatou.iapi.fundstrategy.service.FundStrategyCreateCall;
import com.ymatou.iapi.fundstrategy.service.FundStrategyQueryCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.YmtFundStrategy;
import com.ymttest.database.sqlwapper.YmtFundDimensionWapper;
import com.ymttest.database.sqlwapper.YmtFundStrategyWapper;
import com.ymttest.utils.JsonBeanHelper;
import com.ymttest.utils.YMTDateUtil;
/**
*收佣费率查询接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_ChargeCommissionRateGet{
	private static ChargeCommissionRateGetCall chargecommissionrategetCall;
	private static FundStrategyCreateCall fundstrategycreateCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("资金策略查询接口");
	}

	@Before
	public void caseUp() {
		chargecommissionrategetCall=new ChargeCommissionRateGetCall();
		fundstrategycreateCall=new FundStrategyCreateCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(chargecommissionrategetCall.getOpurl());
	}

	/**
	 * chargecommissionrateget接口返回信息公用错误信息部分断言（正向Case场景）
	 * @throws Exception
	 */	
	public static void  chargeCommissionRateGetreturncode() throws Exception {
	    try {	    	
			//获取返回报文的数据
			String dataStr = chargecommissionrategetCall.getReturnData();
			//返回报文断言
			Logger.verifyNotNull(dataStr, "返回报文非空");			
			String Success =  new JSONObject(dataStr).getString("Success");
			Logger.verifyIsContains(true, Success, "\"Success\":true");
			String errMsg =  new JSONObject(dataStr).getString("ErrMsg");
			Logger.verifyIsNull(errMsg, "Msg等于空");
			String errCode =  new JSONObject(dataStr).getString("ErrCode");
			Logger.verifyIsNull(errCode, "ErrCode等于空");
			String body =  new JSONObject(dataStr).getString("Body");
			Logger.verifyIsNull(body, "Body等于空");
			String requestUrl =  new JSONObject(dataStr).getString("RequestUrl");
			Logger.verifyIsNull(requestUrl, "RequestUrl等于空");
	    	    	    	
	    }catch (Exception e) {  
	        e.printStackTrace();
	    }  

	}
	
	/**
	 * 错误信息断言
	 * @param errcode 错误代码
	 * @param eMsg 错误信息
	 * @throws Exception
	 */
	public void  chargeCommissionRateGetreturnerrcode(String ecode,String eMsg) throws Exception {
	    try {
	    	
			//获取返回报文的数据
			String dataStr = chargecommissionrategetCall.getReturnData();
			//返回报文断言			
			String productCommissionList =  new JSONObject(dataStr).getString("ProductCommissionList");
			Logger.verifyIsNull(productCommissionList, "ProductCommissionList为空");
			String errCode =  new JSONObject(dataStr).getString("ErrCode");
			Logger.verifyIsContains(ecode, errCode, "ErrCode");
			String errMsg =  new JSONObject(dataStr).getString("ErrMsg");
			Logger.verifyIsContains(eMsg, errMsg, eMsg);
			String body =  new JSONObject(dataStr).getString("Body");
			Logger.verifyIsNull(body, "Body为空");
			String requestUrl =  new JSONObject(dataStr).getString("RequestUrl");
			Logger.verifyIsNull(requestUrl, "RequestUrl为空");
			String Success =  new JSONObject(dataStr).getString("Success");
			Logger.verifyIsContains(false, Success, "\"Success\":false");
	    	    	    	
	    }catch (Exception e) {  
	        e.printStackTrace();
	    }  

	}
	
	/**
	 * 当收佣策略查询结果为全局策略时的断言方法
	 * @throws Exception
	 */
	public void  fundSQgetreturnglobalStrategy() throws Exception {
	    try {
	    	
			//ymt_fundstrategy inner join ymt_fundstrategydimension
			YmtFundDimensionWapper ymtFundDimensionWapper = new YmtFundDimensionWapper();	    	
	        List<Map> fundstdi = ymtFundDimensionWapper.selectstrategyidbyrange("100");
	        
			//获取返回报文的数据
			String dataStrQuery = chargecommissionrategetCall.getReturnData();
			//返回报文断言		
			String Success =  new JSONObject(dataStrQuery).getString("Success");
			Logger.verifyIsContains(Success, true, "\"Success\":true");
			String errCode =  new JSONObject(dataStrQuery).getString("ErrCode");
			Logger.verifyIsNull(errCode, "ErrCode等于空");
			String errMsg =  new JSONObject(dataStrQuery).getString("ErrMsg");
			Logger.verifyIsNull(errMsg, "ErrMsg等于空");
			String body =  new JSONObject(dataStrQuery).getString("Body");
			Logger.verifyIsNull(body, "Body等于空");
			String requestUrl =  new JSONObject(dataStrQuery).getString("RequestUrl");
			Logger.verifyIsNull(requestUrl, "RequestUrl等于空");			
			String stid=(String) fundstdi.get(0).get("StrategyId");
			Logger.verifyEquals(stid,  new JSONObject(dataStrQuery).getJSONArray("ProductCommissionList").getJSONObject(0).getString("StrategyId"), "策略Id对比");
			BigDecimal stAmount= (BigDecimal) fundstdi.get(0).get("StrategyAmount"); //数据库查询结果
			double stAmountbyapi=new JSONObject(dataStrQuery).getJSONArray("ProductCommissionList").getJSONObject(0).getDouble("ChargeCommissionRate"); //返回报文结果
			Logger.verifyEquals(stAmount,  new BigDecimal(stAmountbyapi).setScale(2,BigDecimal.ROUND_HALF_UP), "策略费率对比");		
			int stlevel= (int) fundstdi.get(0).get("strategyleveltype");						
			Logger.verifyEquals(stlevel,  new JSONObject(dataStrQuery).getJSONArray("ProductCommissionList").getJSONObject(0).getInt("StrategyLevelType"), "策略级别对比");
	    	    	    	
	    }catch (Exception e) {  
	        e.printStackTrace();
	    }  

	}
	
	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_001() {
		Logger.start(true,"收佣费率查询");
		try {
			//TODO 补全case代码
			//使用维度名称查询维度ID的方法
			String[] fundDimensionidformsql = YmtFundDimensiongetDimensionid.ymtFundDimensiongetDimensionid();				
			//新建一条策略数据					
			FundStrategyCreateBean fundstrategycreateBean = FundStrategy.fundStrategyCreate(1,  		//1为收佣策略
					YMTDateUtil.getBeforeOrNextDay(-100),
					1,		//1特殊策略 2全局策略
					112233,
					"自动化测试人员",
					fundDimensionidformsql[0],	//商品类目维度的Dimensionid
					fundDimensionidformsql[1],	//商品价格维度的Dimensionid
					fundDimensionidformsql[2]); //国家维度的Dimensionid			
			fundstrategycreateCall.setData(fundstrategycreateBean);
			fundstrategycreateCall.callService();
			//获取返回报文的数据
			String dataStrCreate = fundstrategycreateCall.getReturnData();
			//获取返回报文的strategyId值
			String strategyIdbyCreate =  new JSONObject(dataStrCreate).getString("StrategyId");
						
			//
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);
			String categoryidforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(0).getStrategyDimensionIdentityId();
			String countryIdforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(2).getStrategyDimensionIdentityId();
			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", categoryidforCrete);		//商品类目id
			aa.put("CountryId", countryIdforCrete);		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();			
			//接口信息断言
			chargeCommissionRateGetreturncode();
			String dataStr = chargecommissionrategetCall.getReturnData();
			//策略id对比断言
			String strategyIdbyRateGet = new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getString("StrategyId");
			Logger.verifyIsContains(strategyIdbyCreate, strategyIdbyRateGet, "策略id对比");
			//策略费对比断言
			BigDecimal strategyAmountbyCrete = fundstrategycreateBean.getFundStrategy().getStrategyAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
			String chargeCommissionRate = new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getString("ChargeCommissionRate");
			Logger.verifyIsContains(strategyAmountbyCrete, chargeCommissionRate, "策略费对比");
			//策略费用上限对比断言
			BigDecimal strategyMaxAmountbyCrete = fundstrategycreateBean.getFundStrategy().getStrategyMaxAmount().setScale(1,BigDecimal.ROUND_HALF_UP);
			String maxCommissionAmount = new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getString("MaxCommissionAmount");
			Logger.verifyIsContains(strategyMaxAmountbyCrete, maxCommissionAmount, "策略费用上限对比");
			//策略费用下限对比断言
			BigDecimal strategyMinAmountbyCrete = fundstrategycreateBean.getFundStrategy().getStrategyMinAmount().setScale(1,BigDecimal.ROUND_HALF_UP);
			String minCommissionAmount = new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getString("MinCommissionAmount");
			Logger.verifyIsContains(strategyMinAmountbyCrete, minCommissionAmount, "策略费用下限对比");
			String strategyLevelType = new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getString("StrategyLevelType");
			Logger.verifyIsContains(1, strategyLevelType, "策略级别对比");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_002() {
		Logger.start(false,"订单号不能为空");
		try {
			//TODO 补全case代码
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);

			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", null);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", "1313");		//商品类目id
			aa.put("CountryId", "0");		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();	
			
			chargeCommissionRateGetreturnerrcode("1001","订单号不能为空！");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_003() {
		Logger.start(false,"支付时间不能为空");
		try {
			//TODO 补全case代码
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);

			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", null);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", "1313");		//商品类目id
			aa.put("CountryId", "0");		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();	
			
			chargeCommissionRateGetreturnerrcode("1002","支付时间不能为空!");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_004() {
		Logger.start(false,"商品信息集合不能为空");
		try {
			//TODO 补全case代码
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);

			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList", null);			//商品信息集合
			aa.put("CountryId", "0");		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();	
			
			chargeCommissionRateGetreturnerrcode("1005","商品信息集合不能为空!");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_005() {
		Logger.start(false,"商品类目不能为空");
		try {
			//TODO 补全case代码
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);

			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", null);		//商品类目id
			aa.put("CountryId", "0");		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();	
			
			chargeCommissionRateGetreturnerrcode("1101","商品类目不能为空!");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_006() {
		Logger.start(false,"商品卖价不能小于0");
		try {
			//TODO 补全case代码
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);

			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "-1");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", "1313");		//商品类目id
			aa.put("CountryId", "0");		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();	
			
			chargeCommissionRateGetreturnerrcode("1104","商品卖价不能小于0!");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_007() {
		Logger.start(false,"商品Id不能为空");
		try {
			//TODO 补全case代码
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);

			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", "1313");		//商品类目id
			aa.put("ProductInfoList[0]->ProductId", null);		//商品类目id
			aa.put("CountryId", "0");		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();	
			
			chargeCommissionRateGetreturnerrcode("1106","商品Id不能为空!");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_008() {
		Logger.start(false,"商品买家不能为空");
		try {
			//TODO 补全case代码
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);

			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", "1313");		//商品类目id
			aa.put("BuyerId", null);		//商品类目id
			aa.put("CountryId", "0");		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();	
			
			chargeCommissionRateGetreturnerrcode("1108","商品买家卖家信息不能为空！");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_009() {
		Logger.start(false,"商品卖家不能为空");
		try {
			//TODO 补全case代码
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);

			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", "1313");		//商品类目id
			aa.put("SellerId", null);		//商品类目id
			aa.put("CountryId", "0");		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();	
			
			chargeCommissionRateGetreturnerrcode("1108","商品买家卖家信息不能为空！");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_010() {
		Logger.start(false,"卖家所在国家Id不能为空");
		try {
			//TODO 补全case代码
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);

			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", "1313");		//商品类目id
			aa.put("CountryId", null);		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();	
			
			chargeCommissionRateGetreturnerrcode("1109","卖家所在国家Id不能为空!");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_011() {
		Logger.start(true,"时间范围内<取特殊策略>");
		try {
			//TODO 补全case代码
			//使用维度名称查询维度ID的方法
			String[] fundDimensionidformsql = YmtFundDimensiongetDimensionid.ymtFundDimensiongetDimensionid();				
			//新建一条策略数据					
			FundStrategyCreateBean fundstrategycreateBean = FundStrategy.fundStrategyCreate(1, 			 //1为收佣策略 2退佣策略 3返佣策略
					YMTDateUtil.getBeforeOrNextDay(-100),
					1,		//1特殊策略 2全局策略
					112233,
					"自动化测试人员",
					fundDimensionidformsql[0],	//商品类目维度的Dimensionid
					fundDimensionidformsql[1],	//商品价格维度的Dimensionid
					fundDimensionidformsql[2]); //国家维度的Dimensionid
			
			fundstrategycreateCall.setData(fundstrategycreateBean);
			fundstrategycreateCall.callService();
			
			//获取返回报文的数据
			String dataStrCreate = fundstrategycreateCall.getReturnData();
			//获取返回报文的strategyId值
			String strategyIdbyCreate =  new JSONObject(dataStrCreate).getString("StrategyId");
			
			//
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(0);
			String categoryidforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(0).getStrategyDimensionIdentityId();
			String countryIdforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(2).getStrategyDimensionIdentityId();
			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", categoryidforCrete);		//商品类目id
			aa.put("CountryId", countryIdforCrete);		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();			
			//接口信息断言
			chargeCommissionRateGetreturncode();
			String dataStr = chargecommissionrategetCall.getReturnData();

			//SQL Ymt_FundStrategy ymtfp库
			YmtFundStrategyWapper ymtFundStrategyWapper = new YmtFundStrategyWapper();			
			List<YmtFundStrategy> strategyIdlist = ymtFundStrategyWapper.selectstrategy(strategyIdbyCreate);
			YmtFundStrategy ymtFundStrategy = strategyIdlist.get(0);
			
			BigDecimal stamount=ymtFundStrategy.getStrategyAmount().setScale(2,BigDecimal.ROUND_HALF_UP);
			BigDecimal stmaxamout=ymtFundStrategy.getStrategyMaxAmount().setScale(1,BigDecimal.ROUND_HALF_UP);
			BigDecimal stminamout=ymtFundStrategy.getStrategyMinAmount().setScale(1,BigDecimal.ROUND_HALF_UP);
			int slt=ymtFundStrategy.getStrategyLevelType(); 	//策略级别
			
			
			String strategyIdbyquery =  new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getString("StrategyId");
			Logger.verifyIsContains(strategyIdbyCreate, strategyIdbyquery, "策略id对比");
			Double strategyAmountbyquery =  new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getDouble("ChargeCommissionRate");
			Logger.verifyIsContains(stamount, strategyAmountbyquery, "策略费率对比");
			Double strategyMaxAmountbyquery =  new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getDouble("MaxCommissionAmount");
			Logger.verifyIsContains(stmaxamout, strategyMaxAmountbyquery, "策略最高费用对比");
			Double strategyMinAmountbyquery =  new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getDouble("MinCommissionAmount");
			Logger.verifyIsContains(stminamout, strategyMinAmountbyquery, "策略最低费用对比");
			int strategyLevelbyquery =  new JSONObject(dataStr).getJSONArray("ProductCommissionList").getJSONObject(0).getInt("StrategyLevelType");
			Logger.verifyIsContains(slt, strategyLevelbyquery, "策略级别对比");	

			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_012() {
		Logger.start(true,"时间范围外<取全局策略>");
		try {
			//TODO 补全case代码
			//使用维度名称查询维度ID的方法
			String[] fundDimensionidformsql = YmtFundDimensiongetDimensionid.ymtFundDimensiongetDimensionid();				
			//新建一条策略数据					
			FundStrategyCreateBean fundstrategycreateBean = FundStrategy.fundStrategyCreate(1, 			 //1为收佣策略 2退佣策略 3返佣策略
					YMTDateUtil.getBeforeOrNextDay(-100),
					1,		//1特殊策略 2全局策略
					112233,
					"自动化测试人员",
					fundDimensionidformsql[0],	//商品类目维度的Dimensionid
					fundDimensionidformsql[1],	//商品价格维度的Dimensionid
					fundDimensionidformsql[2]); //国家维度的Dimensionid
			
			fundstrategycreateCall.setData(fundstrategycreateBean);
			fundstrategycreateCall.callService();
			
			//获取返回报文的数据
			String dataStrCreate = fundstrategycreateCall.getReturnData();
			//获取返回报文的strategyId值
			String strategyIdbyCreate =  new JSONObject(dataStrCreate).getString("StrategyId");
			
			//
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(-150);
			String categoryidforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(0).getStrategyDimensionIdentityId();
			String countryIdforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(2).getStrategyDimensionIdentityId();
			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", categoryidforCrete);		//商品类目id
			aa.put("CountryId", countryIdforCrete);		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();						
			//取全局时的断言
			fundSQgetreturnglobalStrategy();
						
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_013() {
		Logger.start(true,"类目范围外<取全局策略>");
		try {
			//TODO 补全case代码
			//使用维度名称查询维度ID的方法
			String[] fundDimensionidformsql = YmtFundDimensiongetDimensionid.ymtFundDimensiongetDimensionid();				
			//新建一条策略数据					
			FundStrategyCreateBean fundstrategycreateBean = FundStrategy.fundStrategyCreate(1, 			 //1为收佣策略 2退佣策略 3返佣策略
					YMTDateUtil.getBeforeOrNextDay(-100),
					1,		//1特殊策略 2全局策略
					112233,
					"自动化测试人员",
					fundDimensionidformsql[0],	//商品类目维度的Dimensionid
					fundDimensionidformsql[1],	//商品价格维度的Dimensionid
					fundDimensionidformsql[2]); //国家维度的Dimensionid
			
			fundstrategycreateCall.setData(fundstrategycreateBean);
			fundstrategycreateCall.callService();
			
			//获取返回报文的数据
			String dataStrCreate = fundstrategycreateCall.getReturnData();
			//获取返回报文的strategyId值
			String strategyIdbyCreate =  new JSONObject(dataStrCreate).getString("StrategyId");
			
			//
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(-150);
			String categoryidforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(0).getStrategyDimensionIdentityId();
			String countryIdforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(2).getStrategyDimensionIdentityId();
			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", "509173895713897891798");		//商品类目id
			aa.put("CountryId", countryIdforCrete);		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();						
			//取全局时的断言
			fundSQgetreturnglobalStrategy();
						
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_ChargeCommissionRateGet_014() {
		Logger.start(true,"国家不一致<取全局策略>");
		try {
			//TODO 补全case代码
			//使用维度名称查询维度ID的方法
			String[] fundDimensionidformsql = YmtFundDimensiongetDimensionid.ymtFundDimensiongetDimensionid();				
			//新建一条策略数据			
			FundStrategyCreateBean fundstrategycreateBean = FundStrategy.fundStrategyCreate(1, 			 //1为收佣策略 2退佣策略 3返佣策略
					YMTDateUtil.getBeforeOrNextDay(-100),
					1,		//1特殊策略 2全局策略
					112233,
					"自动化测试人员",
					fundDimensionidformsql[0],	//商品类目维度的Dimensionid
					fundDimensionidformsql[1],	//商品价格维度的Dimensionid
					fundDimensionidformsql[2]); //国家维度的Dimensionid
			
			fundstrategycreateCall.setData(fundstrategycreateBean);
			fundstrategycreateCall.callService();
			
			//获取返回报文的数据
			String dataStrCreate = fundstrategycreateCall.getReturnData();
			//获取返回报文的strategyId值
			String strategyIdbyCreate =  new JSONObject(dataStrCreate).getString("StrategyId");
			
			//
			int num1 = (int)(Math.random()*1000000000);
			String lastPaidDate = YMTDateUtil.getBeforeOrNextDay(-150);
			String categoryidforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(0).getStrategyDimensionIdentityId();
			String countryIdforCrete = fundstrategycreateBean.getFundStrategy().getStrategyDetailList().get(2).getStrategyDimensionIdentityId();
			//修改ChargeCommissionRateGet接口参数
			Map<String,Object> aa = new HashMap<String, Object>();
			aa.put("OrderId", num1);		//订单id 如果订单重复，会返回第一次查询结果的缓存
			aa.put("LastDatePaid", lastPaidDate);			//业务发生日期
			aa.put("ProductInfoList[0]->ProductPrice", "100");			//订单价格
			aa.put("ProductInfoList[0]->CategoryId", "509173895713897891798");		//商品类目id
			aa.put("CountryId", countryIdforCrete+"1");		//国家id
			//调用接口json文件
			JSONObject chargeCommissionRateGetBean =  JsonBeanHelper.getJsonBean("/com.ymatou.iapi.fundcommission/ChargeCommissionRateGet.json");
			chargeCommissionRateGetBean = JsonBeanHelper.updateJsonBean(chargeCommissionRateGetBean, aa);
			
			chargecommissionrategetCall.setData(chargeCommissionRateGetBean);
			chargecommissionrategetCall.callService();						
			//取全局时的断言
			fundSQgetreturnglobalStrategy();
						
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
		
}